class Solution:
    def __init__(self):
        self.path=[]
        self.paths=[]
    def permute(self, nums):
        usage_list=[False]*len(nums)
        self.backtracking(nums,usage_list)
        return self.paths
    def backtracking(self,nums,usage_list):
        if len(self.path)==len(nums):
            self.paths.append(self.path[:])
            return
        for i in range(0,len(nums)):
            if usage_list[i]==True:
                continue
            usage_list[i]=True
            self.path.append(nums[i])
            self.backtracking(nums,usage_list)
            self.path.pop()
            usage_list[i]=False
s=Solution()
N=int(input())
lt=[]
for i in range(N):
    lt.append(chr(ord('A')+i))
result=s.permute(lt)
for i in result:
    for j in i:
        print(j,end='')
    print()